@extends('admin.main')
@section('content')
    <div class="admin-biaogelist">
        <div class="daohang">
            <ul>
                <li>
                    <button type="button" class="am-btn am-btn-default am-radius am-btn-xs"> 医师坐诊管理</button>
                </li>
            </ul>
        </div>

        <div class="listbiaoti am-cf">
            <ul class="am-icon-flag on"> 医师坐诊列表</ul>

            <dl class="am-icon-home" style="float: right;"> 当前位置： 首页 > <a href="#">医师坐诊列表</a></dl>

        </div>
        <div class="am-btn-toolbars am-btn-toolbar am-kg">
            <ul>
                <form action="{{urlAdmin('doctor','getWorkTimeIndex')}}" method="get">
                    <li><input type="text" class="am-form-field am-input-sm am-input-xm" name="keywords" placeholder="输入医师名称" /></li>
                    <li><button type="submit" class="am-btn am-radius am-btn-xs am-btn-success" style="margin-top: -1px;">搜索</button></li>
                </form>
            </ul>
        </div>
        <form class="am-form am-g">
            <table width="100%" class="am-table am-table-bordered am-table-radius am-table-striped">
                <thead>
                <tr class="am-success">
                    <th class="table-id">ID</th>
                    <th class="table-type">医师名称</th>
                    <th class="table-author">预约类型</th>
                    <th class="table-date am-hide-sm-only">安排时段</th>
                    <th class="table-date am-hide-sm-only">坐诊计划期至</th>
                    <th class="table-date am-hide-sm-only">状态</th>
                    <th width="163px" class="table-set">操作</th>
                </tr>
                </thead>
                <tbody>
                @if(!empty($res['data']))
                    @foreach($res['data'] as $v)
                        <tr>
                            <td>{{$v['id']}}</td>
                            <td>{{$v['name']}}</td>
                            <td class="am-hide-sm-only">@if(isset($v['apointment_type']))@if($v['apointment_type']==1) 门诊  @else 电话 @endif @else 无 @endif</td>
                            <td class="am-hide-sm-only">@if(isset($v['work_type']))@if($v['work_type']==1) 全天 @endif @if($v['work_type']==2) 上午 @endif @if($v['work_type']==3) 下午 @endif @else 无 @endif</td>
                            <th class="table-date" style="color: #666">坐诊计划期至@if(isset($v['work_type'])){{$v['add_time']}}@endif</th>
                            <th class="table-date" style="color: #666">@if($v['status']==1)<button class="am-btn am-btn-success am-radius">正常</button> @else <button class="am-btn am-btn-danger am-radius">禁用</button> @endif</th>
                            <td>@if($v['status']==0)<a href="javascript:void(0)" onclick="op(this,{{$v['id']}},1)" class="abtn">开启</a>@else<a href="javascript:void(0)" onclick="op(this,{{$v['id']}},0)" class="abtn">暂停</a> @endif<a href="{{urlAdmin('doctor','getWorkTimeList')}}?id={{$v['id']}}" class="abtn ff6600">编辑</a></td>
                        </tr>
                     @endforeach
                @else
                <tr>
                    <td colspan="7" style="text-align: center"><span>暂无数据~</span></td>

                </tr>
                @endif
                </tbody>
            </table>
            <ul class="am-pagination am-fr">
                @if(isset($res['prev_page_url']))
                    <li><a href="{{$res['prev_page_url']}}">«</a></li>
                @endif
                @foreach($res['pageNoList'] as $v)
                    @if($res['current_page']==$v)
                    <li class="am-active"><a href="{{urlAdmin("doctor",'getWorkTimeIndex')}}?page={{$v}}">{{$v}}</a></li>
                    @else
                        <li><a href="{{urlAdmin("doctor",'getWorkTimeIndex')}}?page={{$v}}">{{$v}}</a></li>
                    @endif
                @endforeach
                    @if(isset($res['next_page_url']))
                        <li><a href="{{$res['next_page_url']}}">»</a></li>
                    @endif
            </ul>
    @include('admin.footer')
            @section('script')
                <script>
                    function op(_this,id,ver) {
                        if (ver==1){
                             str = '开启';
                        }else{
                             str = '暂停';
                        }
                        layer.confirm('您确定要'+str+'吗？', {
                            btn: ['确定', '取消'] //按钮
                        }, function () {
                            $.ajax({
                                type: "get",
                                url: "{{urlAdmin('doctor','getChangeDocState')}}?id=" + id+"&status="+ver,
                                dataType: "json",
                                success: function (res) {
                                    if (res['state'] == 1) {
                                        layer.msg(str+"成功", {icon: 6}, function () {
                                            if(ver==1) {
                                                _this.innerHTML = "暂停";
                                            }
                                            if(ver==0) {
                                                _this.innerHTML = "开启";
                                            }
                                        });
                                    } else {
                                        layer.msg(str+"失败", {icon: 5});
                                    }
                                }
                            })
                        });
                    }
                </script>
@endsection
@endsection